/* -----------------------------------------------------------------------
 * Demonstration of how to write unit tests for dominion-base
 * Include the following lines in your makefile:
 *
 * unittest2: unittest2.c dominion.o rngs.o
 *      gcc -o testUpdateCoins -g  unittest2.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
	//testing smithy card: This one was one I threw an error into, so a good one for me to start practicing on
	struct gameState G;
	int numPlayer = 2;
	int seed = 2;
	int player = 0;//just player 0 for now
	int k[10] = {adventurer, council_room, feast, gardens, mine
		, remodel, smithy, village, baron, great_hall};
	
	
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, deciding later if this is necessary
	int coin_bonus=0;
	int startingDeckCount = G.deckCount[player];
	int startingHandCount = G.handCount[player];
	
	//set the first card in hand to be something
	G.hand[player][0] = curse;
	int handPos = 0;

	
	//after card effect is run, should have 3 less in deck, 2 more in hand (because we played and thus removed a card from hand)
	//though it says "discard" in the fxn, what it means is remove from playable hand. It does not go into the discard pile until another function tells it to.
	cardEffect(smithy,0,0,0,&G,handPos,&coin_bonus);
	
	if ((G.deckCount[player]==(startingDeckCount - 3)) && (G.handCount[player]==(startingHandCount +2)))  {
			printf("Passed basic card test\n");
	}
	else{
			printf("Failed basic card test\n");
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	
	
	
	
	
	
	//what happens if there are no cards to draw from in draw pile or discard pile?
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, deciding later if this is necessary
	G.deckCount[player]=0;//remove cards from deck
	startingDeckCount = G.deckCount[player];
	startingHandCount = G.handCount[player];
	

	cardEffect(smithy,0,0,0,&G,handPos,&coin_bonus);
	
	//no cards to draw, so should simply remove the card played, add to the played card count, and leave the deck count at zero
	if ((G.handCount[player] == (startingHandCount -1)) &&(G.playedCardCount == 1)&&(G.deckCount[player]==0)    ){ 
		printf("Passed no cards left test\n");
	}
	else{
		printf("Failed no cards left test\n");
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
	
	//what happens if there are no cards to draw from in draw pile, but there are cards in the discard pile?
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, deciding later if this is necessary
	G.deckCount[player]=0;//remove cards from deck
	G.discardCount[player]=10;
	startingDeckCount = G.deckCount[player];
	startingHandCount = G.handCount[player];
	
	cardEffect(smithy,0,0,0,&G,handPos,&coin_bonus);
	
	//now we have cards in the discard pile, so hand count should decrement by one, playedCard increment by one, and all 10
	//of the discard pile should move into the deckCount, then be decremented by 3 to be 7
	if ((G.handCount[player] == (startingHandCount + 2)) &&(G.playedCardCount ==1)&&(G.deckCount[player]==7) && (G.discardCount[player]==0)     ){ 
		printf("Passed reshuffle discarded cards into empty deck test\n");
	}
	else{
		printf("Failed reshuffle discarded cards into empty deck test\n");
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	
	
	
//	printf("Deck count before cardEffect: %d\n", G.deckCount[player]);
//	printf("Discard count before cardEffect: %d\n", G.discardCount[player]);
//	printf("Played count before cardEffect: %d\n", G.playedCardCount);
//	printf("Hand count before cardEffect: %d\n", G.handCount[player]);
//	
//	printf("Deck count after cardEffect: %d\n", G.deckCount[player]);
//	printf("Discard count after cardEffect: %d\n", G.discardCount[player]);
//	printf("Hand count after cardEffect: %d\n", G.handCount[player]);
//	printf("Played count after cardEffect: %d\n", G.playedCardCount);


	//	printf("numPlayers: %d\n",G.numPlayers); //number of players
	
	//  printf("embargoTokens: %d\n",G.embargoTokens[treasure_map+1]);
	//	printf("outpostPlayed: %d\n",G.outpostPlayed);
	//	printf("outpostTurn: %d\n",G.outpostTurn);
	//	printf("whoseTurn: %d\n",G.whoseTurn);
	//	printf("whoseTurn: %d\n",G.phase);
	//	printf("numActions: %d\n",G.numActions); /* Starts at 1 each turn */
	//	printf("coins: %d\n",G.coins); /* Use as you see fit! */
	//	printf("numBuys: %d\n",G.numBuys); /* Starts at 1 each turn */
	//	printf("hand: %d\n",G.hand[MAX_PLAYERS][MAX_HAND]);
	//	printf("handCount: %d\n",G.handCount[MAX_PLAYERS]);
	//	printf("deck: %d\n",G.deck[MAX_PLAYERS][MAX_DECK]);
	//	printf("deckCount: %d\n",G.deckCount[MAX_PLAYERS]);
	//	printf("discard: %d\n",G.discard[MAX_PLAYERS][MAX_DECK]);
	//	printf("discardCount: %d\n",G.discardCount[MAX_PLAYERS]);
	//	printf("playedCards: %d\n",G.playedCards[MAX_DECK]);
	//	printf("playedCardCount: %d\n",G.playedCardCount);
	
	
	
	return 0;
}
